*appendix tables 1-12

cd "/Users/kevin/Dropbox/TZ ITNs"

set more off
set varabbrev off

use "constructed data/for_analysis.dta", clear

**************
*table A1:  summary stats
***************
sum $approve if period_90==1 & omitperiod==0 & respondent==1
sum $balance if period_90==1 & omitperiod==0 & respondent==1 & !missing(village_chair)

**************
*table A2:  Table A2:  balance check
***************

foreach y in $balance {  
reg `y' post if period_90==1 & omitperiod==0 & respondent==1, r cluster(dist_id)
estimates store `y'
}
estout $balance, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(post)
esttab $balance using balance_90.tex, se starlevels(* .1 ** .05 *** .01) note(robust standard errors clustered at district level) ///
stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) varlabels(_cons Constant) replace title(covariate balance between respondent pre and post campaign)

*60 days
foreach y in $balance {  
reg `y' post if period_60==1 & omitperiod==0 & respondent==1, r cluster(dist_id)
estimates store `y'
}
estout $balance, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(post)
esttab $balance using balance_60.tex, se starlevels(* .1 ** .05 *** .01) note(robust standard errors clustered at district level) ///
stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) varlabels(_cons Constant) replace title(covariate balance between respondent pre and post campaign)

*120 days
foreach y in $balance {  
reg `y' post if period_120==1 & omitperiod==0 & respondent==1, r cluster(dist_id)
estimates store `y'
}
estout $balance, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(post)
esttab $balance using balance_120.tex, se starlevels(* .1 ** .05 *** .01) note(robust standard errors clustered at district level) ///
stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) varlabels(_cons Constant) replace title(covariate balance between respondent pre and post campaign)

**************
*Table A3: Time trend
**************

*Panel A
 foreach y in $approve {  
reg `y' post##c.time_since_ucc if period_90==1 & omitperiod==0, r cluster(dist_id)
estimates store `y'
}
estout $approve, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(1.post)
esttab $approve using time_trend.tex, se starlevels(* .1 ** .05 *** .01) note(robust standard errors clustered at district level) keep(1.post) ///
stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) varlabels(_cons constant) replace title(treatment interacted with time trend)

*Panel B
 foreach y in $approve {  
reg `y' post##c.time_since_ucc if omitperiod==0, r cluster(dist_id)
estimates store `y'
}
estout $approve, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(1.post)
esttab $approve using time_trend_all.tex, se starlevels(* .1 ** .05 *** .01) note(robust standard errors clustered at district level) keep(1.post) ///
stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) varlabels(_cons constant) replace title(treatment interacted with time trend)

*Panel C
 foreach y in $approve {  
reg `y' post##c.time_since_ucc i.zone if omitperiod==0, r cluster(dist_id)
estimates store `y'
}
estout $approve, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(1.post)
esttab $approve using time_trend_all_zone.tex, se starlevels(* .1 ** .05 *** .01) note(robust standard errors clustered at district level) keep(1.post) ///
stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) varlabels(_cons constant) replace title(treatment interacted with time trend)


**************
*Table A4: missing values
**************
*Panel A
foreach y in $missing {
reg `y' post if period_90==1 & omitperiod==0 & respondent==1, r cluster(dist_id)
  estimates store `y'
  }
estout $missing, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(post)
esttab $missing using attrition.tex, se starlevels(* .1 ** .05 *** .01) note(robust standard errors clustered at district level) ///
stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) varlabels(_cons Constant) replace title(impact of post-campaign survey date on missing response)

*Panel B
foreach y in $missing {
reg `y' post if period_60==1 & omitperiod==0 & respondent==1, r cluster(dist_id)
  estimates store `y'
  }
estout $missing, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(post)
esttab $missing using attrition_60.tex, se starlevels(* .1 ** .05 *** .01) note(robust standard errors clustered at district level) ///
stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) varlabels(_cons Constant) replace title(impact of post-campaign survey date on missing response)

*Panel C
foreach y in $missing {
reg `y' post if period_120==1 & omitperiod==0 & respondent==1, r cluster(dist_id)
  estimates store `y'
  }
estout $missing, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(post)
esttab $missing using attrition_120.tex, se starlevels(* .1 ** .05 *** .01) note(robust standard errors clustered at district level) ///
stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) varlabels(_cons Constant) replace title(impact of post-campaign survey date on missing response)

*********
*Table A5: effect by malaria prevalence
*********

*Panel A
foreach y in $approve {  
reg `y' post_high_malaria high_malaria post if period_90==1 & omitperiod==0, r cluster(dist_id)
estimates store `y'
}
estout $approve, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(post post_high_malaria high_malaria)
esttab $approve using above_median_90.tex, se starlevels(* .1 ** .05 *** .01) replace title(impact of campaign in high prevalence districts)

*Panel B: prevalence with zone fe
foreach y in $approve {  
reg `y' post_high_malaria high_malaria post i.zone if period_90==1 & omitperiod==0, r cluster(dist_id)
estimates store `y'
}
estout $approve, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(post post_high_malaria high_malaria)
esttab $approve using above_median_90_zone.tex, se  starlevels(* .1 ** .05 *** .01) replace title(impact of campaign in high prevalence districts)

*Panel C: 
foreach y in $approve {  
reg `y' post malaria_2000 if period_90==1 & omitperiod==0, r cluster(dist_id)
estimates store `y'
}
estout $approve, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(post)
esttab $approve using malaria_controls.tex, se starlevels(* .1 ** .05 *** .01) note(robust standard errors clustered at district level) ///
stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) varlabels(_cons Constant) replace title(impact of campaign on approval)
  
 **********
*Table A6: registration event placebo
**********
 
 foreach y in $approve {  
reg `y' reg_post if reg_period==1 & reg_omitperiod==0, r cluster(dist_id)
estimates store `y'
}
estout $approve, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(reg_post)
esttab $approve using reg_placebo.tex, se starlevels(* .1 ** .05 *** .01) note(robust standard errors clustered at district level) ///
stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) varlabels(_cons Constant) replace title(registration event placebo)
 
**********
*Table A7: Placebo checks
**********

foreach y in $approve {
    reg `y' post_placebo100 if placebo100_sample==1 & placebo100_omit==0, r cluster(dist_id)
	estimates store `y'
}
 estout $approve, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(post_placebo100 _cons)
 esttab $approve using placebo_100.tex, se starlevels(* .1 ** .05 *** .01) note(robust standard errors clustered at district level) ///
stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) varlabels(_cons Constant) replace title(100 day post-campaign placebo)

foreach y in $approve {
    reg `y' post_placebo200 if placebo200_sample==1 & placebo200_omit==0, r cluster(dist_id)
	estimates store `y'
	}
  estout $approve, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(post_placebo200 _cons)
  esttab $approve using placebo_200.tex, se starlevels(* .1 ** .05 *** .01) note(robust standard errors clustered at district level) ///
stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) varlabels(_cons Constant) replace title(200 day post-campaign placebo)

*negative 100 placebo test

foreach y in $approve {
reg `y' post_placebo_neg100 if placebo_neg100_sample==1 & placebo_neg100_omit==0, r cluster(dist_id)
	estimates store `y'
}
estout $approve, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(post_placebo_neg100 _cons)
esttab $approve using placebo_neg100.tex, se starlevels(* .1 ** .05 *** .01) note(robust standard errors clustered at district level) ///
stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) varlabels(_cons Constant) replace title(100 day pre-campaign placebo)

foreach y in $approve {
 reg `y' post_placebo_neg200 if placebo_neg200_sample==1 & placebo_neg200_omit==0, r cluster(dist_id)
	estimates store `y'
 }
estout $approve, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(post_placebo_neg200 _cons)
esttab $approve using placebo_neg200.tex, se starlevels(* .1 ** .05 *** .01) note(robust standard errors clustered at district level) ///
stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) varlabels(_cons Constant) replace title(200 day pre-campaign placebo)

***********
*Table A8: 
***********

*PANEL A

reg approve_vc1 post_ccm_100 post ccm_100_2010 if period_90==1 & omitperiod==0, r cluster(dist_id)
estimate store reg1
reg approve_vc1 post_ccm_100 post ccm_100_2010  i.zone  if period_90==1 & omitperiod==0, r cluster(dist_id)
estimate store reg2
reg approve_veo1 post_ccm_100 post ccm_100_2010 if period_90==1 & omitperiod==0, r cluster(dist_id)
estimate store reg3
reg approve_veo1 post_ccm_100 post ccm_100_2010 i.zone if period_90==1 & omitperiod==0, r cluster(dist_id)
estimate store reg4
estout reg1 reg2 reg3 reg4, cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(post_ccm_100 post ccm_100_2010 _cons) 
esttab reg1 reg2 reg3 reg4 using ccm_100_2010_90_both.tex, se  starlevels(* .1 ** .05 *** .01) replace title(impact of campaign in CCM vs opposition villages)

*Panel B
reg approve_vc1 post_ccm_pct post ccm_pct if period_90==1 & omitperiod==0, r cluster(dist_id)
estimate store reg1
reg approve_vc1 post_ccm_pct post ccm_pct  i.zone  if period_90==1 & omitperiod==0, r cluster(dist_id)
estimate store reg2
reg approve_veo1 post_ccm_pct post ccm_pct if period_90==1 & omitperiod==0, r cluster(dist_id)
estimate store reg3
reg approve_veo1 post_ccm_pct post ccm_pct i.zone if period_90==1 & omitperiod==0, r cluster(dist_id)
estimate store reg4
estout reg1 reg2 reg3 reg4, cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(post_ccm_pct post ccm_pct _cons) 
esttab reg1 reg2 reg3 reg4 using ccm_pct.tex, se  starlevels(* .1 ** .05 *** .01) replace title(impact of campaign by CCM percent of village leadership)
 
*PANEL C
reg approve_vc1 post_opposition post opposition_50_2010 if period_90==1 & omitperiod==0, r cluster(dist_id)
estimate store reg1
reg approve_vc1 post_opposition post opposition_50_2010 i.zone if period_90==1 & omitperiod==0, r cluster(dist_id)
estimate store reg2
reg approve_veo1 post_opposition post opposition_50_2010 if period_90==1 & omitperiod==0, r cluster(dist_id)
estimate store reg3
reg approve_veo1 post_opposition post opposition_50_2010 i.zone if period_90==1 & omitperiod==0, r cluster(dist_id)
estimate store reg4
estout reg1 reg2 reg3 reg4, cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(post_opposition post opposition_50_2010 _cons) 
esttab reg1 reg2 reg3 reg4 using opp_50_2010_90_both.tex, se  starlevels(* .1 ** .05 *** .01) replace title(impact of campaign in CCM vs opposition villages)

***************
**Table A9: impact of campaign by lagged CCM support
***************

reg village_chair post_ccmvote08 post ccm_vote_lag if period_90==1 & omitperiod==0, r cluster(dist_id)
est store reg1
reg village_chair post_ccmvote08 post ccm_vote_lag  i.zone if period_90==1 & omitperiod==0, r cluster(dist_id)
est store reg2
reg village_exec post_ccmvote08 post ccm_vote_lag  if period_90==1 & omitperiod==0, r cluster(dist_id)
est store reg3
reg village_exec post_ccmvote08 post ccm_vote_lag  i.zone if period_90==1 & omitperiod==0, r cluster(dist_id)
est store reg4
estout reg1 reg2 reg3 reg4, cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(post_ccmvote08 post ccm_vote_lag  _cons) 
esttab reg1 reg2 reg3 reg4 using ccm_08.tex, se  starlevels(* .1 ** .05 *** .01) replace title(impact of campaign by lagged CCM support)

***************
**Table A10: Impact of campaign with controls for 2008 ITN receipt
***************
*Panel A
 foreach y in $approve {  
reg `y' post free_net_all_lag if period_90==1 & omitperiod==0, r cluster(dist_id)
estimates store `y'
}
estout $approve, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(post free_net_all_lag _cons)
esttab $approve using itn08.tex, se starlevels(* .1 ** .05 *** .01) note(robust standard errors clustered at district level) ///
stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) varlabels(_cons Constant) replace title(Controls for 2008 net receipt)

*Panel B
 foreach y in $approve {  
reg `y' post free_net_all_lag i.zone if period_90==1 & omitperiod==0, r cluster(dist_id)
estimates store `y'
}
estout $approve, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(post free_net_all_lag _cons)
esttab $approve using itn08_zone.tex, se starlevels(* .1 ** .05 *** .01) note(robust standard errors clustered at district level) ///
stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) varlabels(_cons Constant) replace title(Controls for 2008 net receipt, zonal fixed effects)

***************
**Table A11: 2010-11 net receipt by political variables
***************

reg free_itnhh approve_vc1_lag post if period_90==1 & omitperiod==0 & respondent==1, r cluster(dist_id)
estimates store reg1
reg free_itnhh approve_vc1_lag post if period_90==1 & omitperiod==0 & respondent==1 & ccm_lag==1, r cluster(dist_id)
estimates store reg2
reg free_itnhh ccm_lag post if period_90==1 & omitperiod==0 & respondent==1, r cluster(dist_id)
estimates store reg3
estout reg1 reg2 reg3, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(approve_vc1_lag ccm_lag)
esttab reg1 reg2 reg3 using itn08_pol.tex, se starlevels(* .1 ** .05 *** .01) note(robust standard errors clustered at district level) ///
stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) varlabels(_cons Constant) replace title(ITN receipt by 2008 political variables)

***************
**Table A12: correlation between approval and vote intention in 2008-09 NPS
***************

corr vote_vc1_lag approve_vc1_lag
corr vote_councillor1_lag approve_councillor1_lag
corr vote_mp1_lag approve_mp1_lag

***************
**Table A13: treatment effect on police, extension officer, headmaster
***************

foreach y in $approve_others {  
reg `y' post if period_90==1 & omitperiod==0, r cluster(dist_id)
estimates store `y'
}
estout $approve_others, style(tex) cells(b(star fmt(3)) se(par)) stats(N, fmt(0) labels("Observations")) starlevels(* .1 ** .05 *** .01) keep(post)
esttab $approve_others using others.tex, se starlevels(* .1 ** .05 *** .01) note(robust standard errors clustered at district level) ///
stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) varlabels(_cons Constant) replace title(impact of campaign on politician approval, 2010 round)
